package com.weiai.wedding.web;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.weiai.wedding.entity.user.MenuTree;
import com.weiai.wedding.service.ShiroDbRealm.ShiroUser;
import com.weiai.wedding.service.user.AuthService;
import com.weiai.wedding.util.ConUtils;

/**
 * 登录跳转主页面控制器
 * 
 * @author wangweiheng
 * 
 */
@Controller
@RequestMapping(value = "/main/main")
public class MainController {
	private static boolean boo=true;
	@Autowired
	private AuthService authService;
	@RequestMapping(value = "")
	public String list(Model model) {
		return "main/main";
	}

	@RequestMapping(value = "tree")
	@ResponseBody
	public List<MenuTree> getZtree() {
		ShiroUser user = ConUtils.getUser();
		if (user == null)
			user = new ShiroUser(null, null,null);
		List<MenuTree> list = authService.getAuth(user.getLoginName());
		return list;
	}

	@RequestMapping(value = "title")
	public String toTitle() {
		return "main/title";
	}

	@RequestMapping(value = "right")
	public String toRight() {
		return "main/right";
	}

	@RequestMapping(value = "home")
	public String toHome() {
		return "main/home";
	}

}
